// See Input.h for details

#include "Input.h"

// Globals

bool Input::PollEvent( Event* event )
{
	if ( SDL_PollEvent( event->tEvent ) )
	{
		switch ( event->tEvent->type )
		{
		case SDL_KEYDOWN:
			event->type = EVENT_KEYDOWN;
			break;
		case SDL_KEYUP:
			event->type = EVENT_KEYUP;
			break;
		case SDL_QUIT:
			event->type = EVENT_QUIT;
			break;
		default:
			event->type = EVENT_NOEVENT;
			break;
		}

		event->key = event->tEvent->key.keysym.sym;

		return true;
	}
	else return false;
}

// Event

Input::Event::Event()
{
	tEvent = new SDL_Event();
}

Input::Event::~Event()
{
	delete tEvent;
}

// Key

Input::Key::Key()
{
}

Input::Key::~Key()
{
}

bool Input::Key::operator==(const char& rhs) const
{
	if (this->id == (int)rhs) return true;
	else return false;
}

bool Input::Key::operator==(const int& rhs) const
{
	if (this->id == rhs) return true;
	else return false;
}

Input::Key::operator char()
{
	return ((char)this->id);
}

Input::Key& Input::Key::operator=(const int& rhs)
{
	this->id = rhs;
	return *this;
}

std::ostream& Input::operator<<(std::ostream& output_stream, const Input::Key& p)
{
	output_stream << p.id;
	return output_stream;
}

